<template>
  <div class="quality-wrapper">
    <ekt-base-icon
      title="质控留痕"
      url="http://say.ektlang.com/static/img/quality.png"
      @handle-click="toggleModal"
    ></ekt-base-icon>

    <ekt-quality-form
      :text="text"
      :content="content"
      :visible.sync="visible"
      @handle-close="toggleModal"
      @handle-submit="submitForm"
    ></ekt-quality-form>
  </div>
</template>

<script>
import cookie from "../../../common/cookie";
import { postSubmitControlUrl } from "../../../common/ajax";
export default {
  props: {
    content: String,
    text: String,
    dateTips: String,
  },
  data() {
    return {
      visible: false,
      isLoading: false,
    };
  },
  methods: {
    submitForm(form) {
      if (this.isLoading) return;
      jQuery.ajax({
        url: postSubmitControlUrl,
        type: 'POST',
        data: {
          uname: cookie.get("nickname"),
          comments: form.comments,
          step_name: form.uname,
          origin_time: this.dateTips, // 查询时间
          origin_html: this.text, // 查询界面
          origin_des: this.content, // 查询内容
        },
        success: res => {
          if (res.success) {
            this.$Message({type:'success',message:'提交成功！'});
            this.isLoading = false;
          }else{
            throwErrorTips('提交失败！',err.msg)
            this.isLoading = false;
          }
        }
      })
    },
    toggleModal() {
      this.visible = !this.visible;
    },
  },
};
</script>

<style lang="less" scoped>
.quality-wrapper {
  display: inline-block;
  vertical-align: middle;
}
</style>